<template>
	<view class="scroll-view_H">		
		<popup-layer ref="popupRef" :direction="'left'">
			<view style="position:absolute;margin-left: 2%;margin-top:15rpx;" @tap="chaxunclose()">
				<image :src="srcfanhui" class="item-icon-sys" mode=""></image>
			</view>
				<view class="box" style="border-bottom: 0px #bfbfbf solid;border-top: 1rpx #bfbfbf solid;padding-top: 5rpx;padding-bottom: 5rpx;">
					<view class="popupspan" style="width: 49.5%;text-align: center;border-right: 1px #bfbfbf solid;padding-left: 0rpx;font-size: 28rpx;" @tap="chaxunreset()">重置</view>
					<view class="popupinput" style="width: 49.5%;text-align: center;color: #6D8AF9;padding-right: 0rpx;" @tap="chaxunok()">确定</view>
				</view>
		</popup-layer>
		<view style="background-color: #FFFFFF;">
			<view class="box">
				<view class="popupspan">单据编号:</view>
				<view class="popupinput">
					<view class="inputff">{{inputdjbh}}</view>
				</view>
			</view>
			<view class="box">
				<view class="popupspan">制单日期:</view>
				<view class="popupinput">
					<view class="inputff">{{inputzdrq}}</view>
				</view>
			</view>
			<view class="box">
				<view class="popupspan">制单部门:</view>
				<view class="popupinput">
					<view class="inputff">{{inputzdbm}}</view>					
			</view>
			</view>
			<view class="box">
				<view class="popupspan">制单人:</view>
				<view class="popupinput">
					<view class="inputff">{{inputzdbm}}</view>
			</view>
			</view>
			<view class="box">
				<view class="popupspan">制单日期:</view>
				<view class="popupinput">
					<view class="inputff">{{inputzdrq}}</view>
			</view>
			</view>			
	
			
		</view>
		
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :down="downOption" :up="upOption" @up="upCallback">
	<view class="" v-for="good in list" :key="good.id">
		<view class="Item">
			<view class="item-link item-content">
				<!--view class="item-inner" @tap="isanAsset($event)" :data-Id="good.Id"-->
				<view class="item-inner" @tap="isanAsset($event)" :data-id="good.Id" :data-AssetId="good.AssetId" :data-DocumentId="good.DocumentId">
					
						
						<view class="item-text">
						<view class="ispan">资产编码:</view><view class="span">{{good.资产编码}}</view>
						</view>
						<view class="item-text">
						<view class="ispan">资产名称:</view><view class="span">{{good.资产名称}}</view>
						</view>
						<view class="item-text">
						<view class="ispan">资产类别:</view><view class="span">{{good.资产类别}}</view>
						</view>
						<view class="item-text">
						<view class="ispan">品牌:</view><view class="span">{{good.品牌}}</view>
						</view>
						<view class="item-text">
						<view class="ispan">规格型号:</view><view class="span">{{good.规格型号}}</view>
						</view>
						<view class="item-text">
						<view class="ispan">购置日期:</view><view class="span">{{good.购置日期}}</view>
						</view>
						<view class="item-text">
						<view class="ispan">已上传图片:</view><view class="span">{{good.是否上传图片}}</view>
						</view>
				</view>
				
			</view>
		</view>
	</view>
	</mescroll-body>

	<tki-tree ref="tkitree" :selectParent="selectParent" :multiple="multiple" :range="treelist" :foldAll="flod" rangeKey="Name" :title="title"
	 @confirm="treeConfirm" @cancel="treeCancel"></tki-tree>
	 
	
	</view>
</template>

<script>
	// 引入mescroll-mixins.js
	import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
	import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
	import popupLayer from "@/components/popup-layer/popup-layer.vue";
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
	import tkiTree from '@/components/tki-tree-asset/tki-tree.vue';
	import auiDialog from '@/components/aui-dialog/aui-dialog.vue';
	import tabBar from '@/components/tabbar/tabbar_add.vue';
	var self;
	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {
			MescrollBody
			,
			MescrollUni
			,
			popupLayer
			,
			tkiTree
			,
			tabBar
		},
		data() {
			return {
				// 下拉刷新的配置(可选, 绝大部分情况无需配置)
				downOption: {
					auto:true,
					native: false,
					beforeEndDownScroll:1000,
					textInOffset:"下拉刷新",
					textOutOffset:"释放刷新",
					textLoading:"加载中..."
				},upOption:{
					auto:true, // 不自动加载
					page: {
						num: 0, // 当前页码,默认1,回调之前会加1,即callback(page)会从1开始
					 	size: 10 // 每页数据的数量
					},
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty:{
						tip: ''
					},
					src: "../../static/images/totop.png",
					offset: 50,
					duration: 100,
					zIndex: 9990,
					right: 20,
					bottom: 120,
					safearea: false,
					width: 72,
					radius: "50%",
					left: null,
				},
				list:[],
				loginName: "",
				searchType:"",
				SumCount:"0",
				srcsys: "../../static/images/icon-sxuan.png",
				srcfanhui: "../../static/images/icon-fanhui-you.png",
				inputgjz:"",
				inputdjbh:"",
				inputzcmc:"",
				inputzdrq:"",
				inputzdbm:"请选择制单部门 >",
				inputzdr:"请选择制单人 >",
				inputsybm:"请选择部门 >",
				inputsyr:"请选择人员 >",
				inputclfs:"请选择处理方式 >",
				inputdjzt:"请选择单据状态 >",
				inputzdbmspan:"使用部门",
				inputzdrspan:"使用人",
				inputghrq:"",
				inputzclbid:"",
				inputzdbmid:"",
				inputzdrid:"",
				inputclfsid:"",
				inputdjztid:"",	
				treelist: [],
				multiple: false,
				selectParent: true,
				flod: false,
				Addflag:false,
				title:"选择资产类别",
				selectvalue:"",
				showTreeValue:false,
				ShowQueryValue:false,
				DocumentId:"",
				deleteids:"",
				DepartmentId:"",
				UserId:"",
				loginid:"",
				loginName: "",
				auiDialog: {
					title: '',
					msg: '',
					btns: [{name: '确定'}],
					mask: true,
					maskTapClose: true,
					items: [],
					theme: 1,
				},
				
			}
		},
		onBackPress(options) {
			if(this.showTreeValue==true){
				this.showTreeValue=false;
				this.$refs.tkitree._hide();
				return true;
			}else{
				if(this.ShowQueryValue==true){
					this.ShowQueryValue=false;
					this.$refs.popupRef.close();
					return true;
				}else{
					return false;
				}
			}			
		}, 
		onNavigationBarButtonTap(val) {
			
		},
		provide(){
			return {
				_mainFuncInit: this._mainFuncInit
			}
		},
		methods: {
			_mainFuncInit(page){
				self=this;
				
					var _newdate=new Date();
				
				this.request_tool({
					url:'/console/app/v1/document-detail/pageData',
					type:'POST',
					data:{
					"pageSize": page.size,
					"current": page.num,
					"id":self.DocumentId
				 }
				}).then(res => {
					console.log(res);
					if(res.data.code==2000){
						
						
						
					}else{
						uni.showToast({
							icon: 'none',
							title: '请求失败'+JSON.stringify(res.data)
						});
					}
					//self.sumCount_ZY=res.data.data.total;
					//uni.setStorageSync("IdexSumCount_ZY",res.data.data.total)
				}).catch(err => {
				  console.error(err);
				  uni.showToast({
					icon: 'none',
					title: '请求异常'+err
				  });
				});
				/*
				uni.request({
					url:uni.getStorageSync("localurl")+'/Documents/Save_Document_Model',
					data: newdata,
					method:"POST",
					success: (res) => {
						console.log(res);
						if (res.data.successed == true) {
							self.inputdjbh=res.data.Code;
							self.DocumentId=res.data.Id;
							if(self.inputzdbmid==""){
								uni.showToast({
									icon: 'none',
									title: '请选择'+self.inputzdbmspan,
									duration: 2000
								});
								return;
							}
							if(self.inputzdrid==""){
								uni.showToast({
									icon: 'none',
									title: '请选择'+self.inputzdrspan,
									duration: 2000
								});
								return;
							}
							this.focusshowasset();
						}
					},
					fail: () => {
						//  请求失败,隐藏加载状态
						this.mescroll.endErr()
					}
				})
				*/
				
				
				
			},
			_initData(){
				this._mainFuncInit();
			},
			/*下拉刷新的回调, 有三种处理方式:*/
			downCallback() {
				this.list=[];
				this.mescroll.resetUpScroll();
			
			},
			/*下拉加载的回调*/
			upCallback(page) {
				self = this;
				if(self.DocumentId!=""){
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				
				
				
				this.request_tool({
					url:'/console/app/v1/document-detail/pageData',
					type:'POST',
					data:{
					"pageSize": page.size,
					"current": page.num,
					"documentId":self.DocumentId
				 }
				}).then(res => {
					console.log(res);
					if(res.data.code==2000){
						let mydata=[];
						self.SumCount=res.data.data.total;
						var newrows = res.data.data.records;
						for (var i = 0; i < newrows.length; i++) {	
							var row=newrows[i];
							var datarow = {
								"Id":row.id,
								"AssetId":row.assetId,
								"DocumentId":row.documentId,
								"资产编码":row.assetInfo.code,
								"资产名称":row.assetInfo.name,
								//"资产类别":row.assetInfo.name,
								"资产类别":row.assetInfo.name,
								"品牌":row.assetInfo.brand,
								"规格型号":row.assetInfo.model,
								"购置日期":self.getstrdate(row.assetInfo.boughtDate),
								"是否上传图片":self.getisupload(row.assetInfo.other)
							};							
							mydata.push(datarow);
							
						}						
						self.list=mydata;
						
						//this.productList = mydata;
						// 接口返回的当前页数据列表 (数组)
						let curPageData = mydata; 
						// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
						let curPageLen = mydata.length; 
						// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
						let totalPage = res.data.total/page.size; 
						// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
						let totalSize = res.data.total; 
						// 接口返回的是否有下一页 (true/false)
						let hasNext =false; 
						 //设置列表数据
						 //console.log(curPageData);
						 if(page.num == 1) this.list = []; //如果是第一页需手动置空列表
						 this.list = this.list.concat(curPageData); //追加新数据
						 
						 // 请求成功,隐藏加载状态
						 //方法一(推荐): 后台接口有返回列表的总页数 totalPage
						 this.mescroll.endByPage(curPageLen, totalPage); 
						 
						 // 如果数据较复杂,可等到渲染完成之后再隐藏下拉加载状态: 如
						 // 建议使用setTimeout,因为this.$nextTick某些情况某些机型不触发
						 setTimeout(()=>{
						 	this.mescroll.endSuccess(curPageLen)
						 },20)
						
					}else{
						uni.showToast({
							icon: 'none',
							title: '请求失败'+JSON.stringify(res.data)
						});
					}
					//self.sumCount_ZY=res.data.data.total;
					//uni.setStorageSync("IdexSumCount_ZY",res.data.data.total)
				}).catch(err => {
				  console.error(err);
				  uni.showToast({
					icon: 'none',
					title: '请求异常'+err
				  });
				});
				
				/*
				uni.request({												
					url:uni.getStorageSync("localurl")+'//Documents/Get_Document_Detail_List',
					data: {
						pageSize: pageSize,
						_r: "dde7a3ef-2a1a-4494-880f-7c4f56dd0f9e",
						pageIndex: pageNum-1,
						DocumentId:self.DocumentId
						
					},
					success: (res) => {
						console.log(res);
						
						if (res.data.successed == true) {
							var mydata = [];
							self.SumCount=res.data.sumCount;
							var newrows = JSON.parse(res.data.rows);
							for (var i = 0; i < newrows.length; i++) {
								var valueRows = newrows[i].toString().split(',');
								var datarow = {};
								for (var j = 0; j < res.data.columns.length; j++) {
									datarow[res.data.columns[j].字段名] = valueRows[j];
								}
								mydata.push(datarow);
								
							}
						console.log(mydata);
							if(mydata.length>0){
								if(mydata[0]["借用部门"]!=undefined){
								self.inputsybm=mydata[0]["借用部门"];
								self.inputsyr=mydata[0]["借用人"];
								}else if(mydata[0]["领用部门"]!=undefined){
									self.inputsybm=mydata[0]["领用部门"];
									self.inputsyr=mydata[0].领用人;
									}
									else if(mydata[0]["使用部门"]!=undefined){
										self.inputsybm=mydata[0].使用部门;
										self.inputsyr=mydata[0].使用人;
										}
									if(mydata[0]["计划归还日期"]!=undefined){
										self.inputghrq=mydata[0].计划归还日期;
										}	
										//
							}
							//this.productList = mydata;
							// 接口返回的当前页数据列表 (数组)
							let curPageData = mydata; 
							// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
							let curPageLen = mydata.length; 
							// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
							let totalPage = res.data.total/page.size; 
							// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
							let totalSize = res.data.total; 
							// 接口返回的是否有下一页 (true/false)
							let hasNext =false; 
							 //设置列表数据
							 //console.log(curPageData);
							 if(page.num == 1) this.list = []; //如果是第一页需手动置空列表
							 this.list = this.list.concat(curPageData); //追加新数据
							 
							 // 请求成功,隐藏加载状态
							 //方法一(推荐): 后台接口有返回列表的总页数 totalPage
							 this.mescroll.endByPage(curPageLen, totalPage); 
							 
							 // 如果数据较复杂,可等到渲染完成之后再隐藏下拉加载状态: 如
							 // 建议使用setTimeout,因为this.$nextTick某些情况某些机型不触发
							 setTimeout(()=>{
							 	this.mescroll.endSuccess(curPageLen)
							 },20)
						
														 
							}
						},
						fail: () => {
								//  请求失败,隐藏加载状态
								this.mescroll.endErr()
							}
						})
						*/
				// 此处仍可以继续写其他接口请求...
				// 调用其他方法...	
												}else{
													this.mescroll.endSuccess(1)
													}
			},
			queryasset(){
				uni.request({
					url:uni.getStorageSync("localurl")+'//Documents/Query_Document_List',
					data: {
						pageSize: 5,
						_r: "dde7a3ef-2a1a-4494-880f-7c4f56dd0f9e",
						pageIndex: 0,
					},
					success: (res) => {
						console.log(res);
						if (res.data.successed == true) {
							//sumCount
							//self.list=res.data;
						}
					},
					fail: () => {
						//  请求失败,隐藏加载状态
						this.mescroll.endErr()
					}
				})
			},
			isanAsset(e){
				console.log(e.currentTarget.dataset.assetid);
				/*
				uni.navigateTo({
					url: '../asset/asset?Id=' + e.currentTarget.dataset.assetid+'&documentDetailId='+e.currentTarget.dataset.id+"&documentId="+e.currentTarget.dataset.documentId,
				});
				*/
				uni.navigateTo({
					url: '../asset/assetedit?documentDetailAssetId=' +  e.currentTarget.dataset.assetid+"&documentId="+e.currentTarget.dataset.DocumentId,
				});
				
			},
			isanselectAsset(e){
				self=this;
				if(self.deleteids.indexOf(e.currentTarget.dataset.id)>-1){
					if(self.deleteids==e.currentTarget.dataset.id){
						self.deleteids="";
					}else{
						self.deleteids=self.deleteids.replace(e.currentTarget.dataset.id+",","");
					}
					}else{
						if(self.deleteids==""){
							self.deleteids=e.currentTarget.dataset.id;
						}else{
							self.deleteids=self.deleteids+","+e.currentTarget.dataset.id;
						}
					
						}
				
			},
			sxchaxun(){
				this.ShowQueryValue=true;
				 this.$refs.popupRef.show();
			},
			chaxunclose(){
				this.ShowQueryValue=false;
				this.$refs.popupRef.close();
			},
			chaxunreset(){
				this.inputzcbm="";
				this.inputzcmc="";
				this.inputzdbm="请选择制单部门";
				this.inputzdr="请选择制单人";
				this.inputclfs="请选择处理方式";
				this.inputdjzt="请选择单据状态";
				this.inputzdbmid="";
				this.inputzdrid="";
				this.inputclfsid="";
				this.inputdjztid="";
				this.ShowQueryValue=false;
				this.$refs.popupRef.close();
				this.downCallback();
			},
				chaxunok(){
					this.ShowQueryValue=false;
					this.$refs.popupRef.close();
					this.downCallback();
				},
				focusshow(e){
					this.selectvalue=e.currentTarget.dataset.id;
					this.treelist=[];
					this.$refs.tkitree.oldtreeList="";
					this.$refs.tkitree.servalue="";
					console.log(e.currentTarget.dataset.id);
					if(e.currentTarget.dataset.id=="sybm"){
						this.showTree();
						this.title="请选择部门";
						this.loadDepartment();
					}else if(e.currentTarget.dataset.id=="syr"){
						
						if(this.inputsybmid=="" || this.inputsybmid==null){
							uni.showToast({
								icon: 'none',
								title: '请选择部门'
							});
							return;
						}else{
							this.showTree();
							this.title="请选择人员";
							this.loadglbmProfile();
						}
					}else if(e.currentTarget.dataset.id=="clfs"){
						if(this.DocumentId==""){
						this.showTree();
						this.title="请选择处理方式";
						this.loadRouteHandler();
						}
					}else if(e.currentTarget.dataset.id=="djzt"){
						this.showTree();
						this.title="请选择单据状态";
						this.loadDictionary();
					}
					
					
				},
				focusshowasset(e){
					this.selectvalue="selzc";
					this.treelist=[];
					this.$refs.tkitree.oldtreeList="";
					this.$refs.tkitree.servalue="";
					
					this.showTree();
					this.title="请选择资产";
					this.loadAssets();
					
					
				},
				// 确定回调事件
				treeConfirm(e) {
					self=this;
					this.showTreeValue=false;
					if(this.selectvalue=="zclb"){
						this.inputzclb=e[0].Name;
						this.inputzclbid=e[0].Id;
					}else if(this.selectvalue=="sybm"){
						this.inputsybm=e[0].Name;
						this.inputsybmid=e[0].Id;
					}else if(this.selectvalue=="syr"){
						this.inputsyr=e[0].Name;
						this.inputsyrid=e[0].Id;
					}else if(this.selectvalue=="clfs"){
						this.inputclfs=e[0].Name;
						this.inputclfsid=e[0].Id;
						if(this.inputclfs=="直接出库"){
							self.inputzdbmspan="使用部门";
							 self.inputzdrspan="使用人";
							}
						if(this.inputclfs=="借用出库"){
													self.inputzdbmspan="借用部门";
													 self.inputzdrspan="借用人";
													}
						if(this.inputclfs=="领用出库"){
													self.inputzdbmspan="领用部门";
													 self.inputzdrspan="领用人";
													}
						
					}else if(this.selectvalue=="djzt"){
						this.inputdjzt=e[0].Name;
						this.inputdjztid=e[0].Id;
					}
					else if(this.selectvalue=="selzc"){
						
						   var added =[];
						   added.push(e[0].Id);
						   uni.request({
						   	url:uni.getStorageSync("localurl")+'//Documents/Asset_Change_Add_Detail_Save',
						   	data: {
						   		_Added: added,
						   		_r: "dde7a3ef-2a1a-4494-880f-7c4f56dd0f9e",
						   		_Removed: [],
								DocumentId:self.DocumentId,
						   	},
							method:"POST",
						   	success: (res) => {
						   		console.log(res);
						   		if (res.data.successed == true) {
						   			this.downCallback();
						   		}
						   	},
						   	fail: () => {
						   		//  请求失败,隐藏加载状态
						   		this.mescroll.endErr()
						   	}
						   })
					}
					
				},
				// 取消回调事件
				treeCancel(e) {
					this.showTreeValue=false;
					console.log(e)
				},	
				// 显示树形选择器
				showTree() {
					this.showTreeValue=true;
					this.$refs.tkitree._show();
				},
				loadAssetType(){
					self=this;
					uni.showNavigationBarLoading();
					uni.request({
						url:uni.getStorageSync("localurl")+'//Common/TreeSelector', //仅为示例，并非真实接口地址。
						data: {
							_Type: "AmsAssetTypes",
						},
						success: res2 => {
							
							if (res2.data.successed == true) {
								//console.log(res2.data.data);
								var _typelist=[];
								for(var i=0;i<res2.data.data.length;i++){
									var model=res2.data.data[i];								
									var child=[];
									var _type={};
									_type.Id=model.Id;
									_type.Name=model.Name;
									for(var j=0;j<model.children.length;j++){
										var model1=model.children[j];
										var child1=[];
										var _type1={};
										_type1.Id=model1.Id;
										_type1.Name=model1.Name;
										for(var s=0;s<model1.children.length;s++){
											var model2=model1.children[s];
											var child2=[];
											var _type2={};
											_type2.Id=model2.Id;
											_type2.Name=model2.Name;
											
											_type2.children=child2;
											child1.push(_type2);									
										}
										_type1.children=child1;
										child.push(_type1);
									}
									
									_type.children=child;
									_typelist.push(_type);
								}
								self.treelist= _typelist;
								setTimeout(function () {
								  uni.hideNavigationBarLoading();
								}, 1000);
								//this.model = res.data.model;
							}
						},
						fail: () => {
					
							uni.showToast({
								icon: 'none',
								title: '网络异常,请稍后重试'
							});
						}
					});
					
				},
				loadDepartment(){
					self=this;
					uni.showNavigationBarLoading();
					uni.request({
						url:uni.getStorageSync("localurl")+'//Common/TreeSelector', //仅为示例，并非真实接口地址。
						data: {
							_Type: "AmsDepartments",
						},
						success: res2 => {
							if (res2.data.successed == true) {
								self.treelist= res2.data.data;
								setTimeout(function () {
								  uni.hideNavigationBarLoading();
								}, 2000);
								
								//this.model = res.data.model;
							}
						},
						fail: () => {
							uni.hideNavigationBarLoading();
							uni.showToast({
								icon: 'none',
								title: '网络异常,请稍后重试'
							});
						}
					});
				},
				loadglbmProfile(){
					self=this;
					uni.showNavigationBarLoading();
					uni.request({
						url:uni.getStorageSync("localurl")+'//Common/TreeSelector', //仅为示例，并非真实接口地址。
						data: {
							_Type: "AmsProfiles",
							DepartmentId:self.inputsybmid,
							pageSize:500
						},
						success: res2 => {
							//console.log(res2);
							if (res2.data.successed == true) {
								var mydata = [];
								var newrows = JSON.parse(res2.data.rows);
								for (var i = 0; i < newrows.length; i++) {
									var valueRows = newrows[i].toString().split(',');
									var datarow = {};
									for (var j = 0; j < res2.data.columns.length; j++) {
										//alert(_data.columns[j].字段名)
										datarow[res2.data.columns[j].字段名] = valueRows[j];
									}
									datarow.children=[];
									datarow.anyChildChecked=null;
									datarow.checked=null;
									datarow.state=null;
									mydata.push(datarow);
									
								}
								
								
								self.treelist=mydata;
								setTimeout(function () {
								  uni.hideNavigationBarLoading();
								}, 2000);
								//this.model = res.data.model;
							}
						},
						fail: () => {
							uni.hideNavigationBarLoading();
							uni.showToast({
								icon: 'none',
								title: '网络异常,请稍后重试'
							});
						}
					});
				},
				loadsybmProfile(){
					self=this;
					uni.showNavigationBarLoading();
					uni.request({
						url:uni.getStorageSync("localurl")+'//Common/TreeSelector', //仅为示例，并非真实接口地址。
						data: {
							_Type: "AmsProfiles",
							DepartmentId:self.inputsybmid,
							pageSize:500
						},
						success: res2 => {
							console.log(res2);
							if (res2.data.successed == true) {
								var mydata = [];
								var newrows = JSON.parse(res2.data.rows);
								for (var i = 0; i < newrows.length; i++) {
									var valueRows = newrows[i].toString().split(',');
									var datarow = {};
									for (var j = 0; j < res2.data.columns.length; j++) {
										//alert(_data.columns[j].字段名)
										datarow[res2.data.columns[j].字段名] = valueRows[j];
									}
									datarow.children=[];
									datarow.anyChildChecked=null;
									datarow.checked=null;
									datarow.state=null;
									mydata.push(datarow);
									
								}
								console.log(mydata);
								
								self.treelist=mydata;
								uni.hideNavigationBarLoading();
								//this.model = res.data.model;
							}
						},
						fail: () => {
							uni.hideNavigationBarLoading();
							uni.showToast({
								icon: 'none',
								title: '网络异常,请稍后重试'
							});
						}
					});
				},
				loadRouteHandler(){
					self=this;
					
					uni.showNavigationBarLoading();
					uni.request({
						url:uni.getStorageSync("localurl")+'//Common/TreeSelector', //仅为示例，并非真实接口地址。
						data: {
							_Type: "AmsRouteHandlers",
							_Root:"793212f5-f44e-4bfa-b46d-0f3bd67b03a9"
						},
						success: res2 => {
							
							if (res2.data.successed == true) {
								//console.log(res2.data.data);
								var _typelist=[];
								for(var i=0;i<res2.data.data.length;i++){
									var model=res2.data.data[i];								
									var child=[];
									var _type={};
									_type.Id=model.Id;
									_type.Name=model.Name;
									for(var j=0;j<model.children.length;j++){
										var model1=model.children[j];
										var child1=[];
										var _type1={};
										_type1.Id=model1.Id;
										_type1.Name=model1.Name;
										for(var s=0;s<model1.children.length;s++){
											var model2=model1.children[s];
											var child2=[];
											var _type2={};
											_type2.Id=model2.Id;
											_type2.Name=model2.Name;
											
											_type2.children=child2;
											child1.push(_type2);									
										}
										_type1.children=child1;
										child.push(_type1);
									}
									
									_type.children=child;
									_typelist.push(_type);
								}
								self.treelist= _typelist;
								setTimeout(function () {
								  uni.hideNavigationBarLoading();
								}, 1000);
								//this.model = res.data.model;
							}
						},
						fail: () => {
					
							uni.showToast({
								icon: 'none',
								title: '网络异常,请稍后重试'
							});
						}
					});
					
				},loadDictionary(){
					self=this;
					
					uni.showNavigationBarLoading();
					uni.request({
						url:uni.getStorageSync("localurl")+'//Common/TreeSelector', //仅为示例，并非真实接口地址。
						data: {
							_Type: "AmsDictionarys",
							_Root:"00000000-0000-0000-0000-000000000001"
						},
						success: res2 => {
							
							if (res2.data.successed == true) {
								//console.log(res2.data.data);
								var _typelist=[];
								for(var i=0;i<res2.data.data.length;i++){
									var model=res2.data.data[i];								
									var child=[];
									var _type={};
									_type.Id=model.Id;
									_type.Name=model.Name;
									for(var j=0;j<model.children.length;j++){
										var model1=model.children[j];
										var child1=[];
										var _type1={};
										_type1.Id=model1.Id;
										_type1.Name=model1.Name;
										for(var s=0;s<model1.children.length;s++){
											var model2=model1.children[s];
											var child2=[];
											var _type2={};
											_type2.Id=model2.Id;
											_type2.Name=model2.Name;
											
											_type2.children=child2;
											child1.push(_type2);									
										}
										_type1.children=child1;
										child.push(_type1);
									}
									
									_type.children=child;
									_typelist.push(_type);
								}
								self.treelist= _typelist;
								setTimeout(function () {
								  uni.hideNavigationBarLoading();
								}, 1000);
								//this.model = res.data.model;
							}
						},
						fail: () => {
					
							uni.showToast({
								icon: 'none',
								title: '网络异常,请稍后重试'
							});
						}
					});
					
				},
				loadAssets(){
					self=this;
					uni.showNavigationBarLoading();
					uni.request({
						url:uni.getStorageSync("localurl")+'//Common/TreeSelector', //仅为示例，并非真实接口地址。
						data: {
							_Type: "AmsAssets",
							pageSize:500
						},
						success: res2 => {
							//console.log(res2);
							if (res2.data.successed == true) {
								var mydata = [];
								var newrows = JSON.parse(res2.data.rows);
								for (var i = 0; i < newrows.length; i++) {
									var valueRows = newrows[i].toString().split(',');
									var datarow = {};
									for (var j = 0; j < res2.data.columns.length; j++) {
										//alert(_data.columns[j].字段名)
										datarow[res2.data.columns[j].字段名] = valueRows[j];
									}
									datarow.children=[];
									datarow.anyChildChecked=null;
									datarow.checked=null;
									datarow.state=null;
									mydata.push(datarow);
									
								}
								//console.log(mydata);
								
								self.treelist=mydata;
								uni.hideNavigationBarLoading();
								//this.model = res.data.model;
							}
						},
						fail: () => {
							uni.hideNavigationBarLoading();
							uni.showToast({
								icon: 'none',
								title: '网络异常,请稍后重试'
							});
						}
					});
				}
				,
				getstrdate(value){
					
						return value.substring(0, 4)+"-"+value.substring(4, 6)+"-"+value.substring(6, 8);
					
				},
				getisupload(other){
					let value=JSON.stringify(other);
					if(value.indexOf("gdzcfile")>-1){
						return "是";
					}else{
						return "否";
					}
					
				}
				,
				request_tool(options){
				 // 在这里可以对请求头进行一些设置
				 let baseUrl = uni.getStorageSync("localurl"); 
				 let userInfo = uni.getStorageSync("userInfo");
				 if (userInfo) {
				 	options.data['userLevelCode'] =JSON.parse(userInfo).levelCode;
				 	options.data['loginUserId'] = JSON.parse(userInfo).id;
				 }
				 let userDept = uni.getStorageSync("userDept");
				 //console.log(userDept);
				 if (userDept) {
				 	options.data['loginUserDeptLevelCode'] = userDept.levelCode;
				 	options.data['loginUserDeptId'] = userDept.id;
				 }
				 let currentRole = uni.getStorageSync("userRoles");
				  //console.log(currentRole);
				 if (currentRole) {
				 	options.data['roleLevelCode'] = currentRole[0].levelCode;
				 	options.data['roleId'] = currentRole[0].id;
				 }
				 let userReadDeptIds = uni.getStorageSync("userReadDeptIds");
				 
				 if (userReadDeptIds) {
				 	options.data['deptIds'] =userReadDeptIds;
				 }
				 
				  options.header = {
				      'Content-Type':'application/json',
				      Authorization: uni.getStorageSync("authorization")
				 }
				//console.log(options);
				    return new Promise((resolve, reject) => {
				        uni.request({
				            url: baseUrl + options.url || '',
				            method: options.type || 'POST',
				            data: options.data || {},
				            header: options.header || {}      
				        }).then(data => {
				            let [err, res] = data;        
				            resolve(res);
				        }).catch(error => {
				            reject(error)
				        })
				    });
				}
		},
		onLoad(options) {
			//首先将实例指针保存到全局变量 self 方便在异步请求中访问实例本身
			
			self=this;
			//底部导航开始
			let temp = uni.getStorageSync('setStatusIndexFunc') || 0
			uni.setStorageSync('setStatusIndexFunc', temp)
			
			const userinfo = uni.getStorageSync("userInfo");
			self.loginid=JSON.parse(userinfo).id;
			self.loginName = JSON.parse(userinfo).userName;
			const userDept = uni.getStorageSync("userDept");
			 var data = {
			            "_r": "661aea12-cb28-4c92-9a78-66c519a630c9",
			            "act": options.act
			        }
			        //使用ID换code
			        if (options.document_id) {
			            data.DocumentId = options.document_id;
						self.DocumentId=options.document_id;
			        }
			//底部导航结束
			//Get_Document_Model
			this.request_tool({
				url:'/console/app/v1/document/pageData',
				type:'POST',
				data:{
			 	"pageSize": 2,
			 	"current": 1,
				"id":self.DocumentId
			 }
			}).then(res => {
				if(res.data.code==2000){
					var mydata = [];
					self.SumCount=res.data.data.total;
					var newrows = res.data.data.records;
					for (var i = 0; i < newrows.length; i++) {	
						var row=newrows[i];						
						self.inputzdr=self.loginName;
						 self.inputzdbm=userDept.orgName;					
						 self.inputzdrq=self.getstrdate(row.createTime);
						 self.inputdjbh=row.code;
						 self.inputdjmc=row.name;						
						
					}
					
					
				}else{
					uni.showToast({
						icon: 'none',
						title: '请求失败'+JSON.stringify(res.data)
					});
				}
				//self.sumCount_ZY=res.data.data.total;
				//uni.setStorageSync("IdexSumCount_ZY",res.data.data.total)
			}).catch(err => {
			  console.error(err);
			  uni.showToast({
			  	icon: 'none',
			  	title: '请求异常'+err
			  });
			});
			
		
			//this.queryasset();
		
		
		}
	}
</script>

<style>
	.item-icon-sys {
		width: 40upx;
		height: 40upx;
	}
.scroll-view_H{
		background-color: #edf1f4;
		padding-left: 10px;
		padding-right: 10px;
	}
	.Item {
		border: 1px solid #e6e6e6;
		overflow: hidden;
		padding-bottom: 16rpx;
		border-radius: 16rpx;
		background: #fff;
		margin-top: 10rpx;
	}
	
	.item-text .span {
		display: inline-block;
		width: 67%;
		float: right;
	}
	
	.item-text .ispan {
		font-style: normal;
		width: 30%;
		display: inline-block;
	}
	
	.item-content {
		padding-left: 0;
	}
	
	.item-title .ispan {
		font-size: 30rpx;
		width: auto;
		height: auto;
	}
	
	.item-title {
		font-size: 40rpx;
		color: #454545;
		width: 100%;
	}
	
	.item-title-row {
		background-image: none;
		padding-right: 0px;
	}
	
	.item-link .item-inner {
		padding-right: 0;
	}
	.item-text {
		font-size: 30rpx;
		color: #454545;
		margin: 20rpx 0;
		padding-left: 20rpx;
		line-height: 1.2;
	}
	
	.box{
		width: 700rpx;border-bottom: 1px #f0f0f0 solid;
		height: 80rpx;
		line-height: 80rpx;
	}
	.box .popupspan{
		width: 36.5%;display: inline-block;height: 80rpx;
		line-height: 80rpx;
		padding-left: 3.5%;
		color: #5a5a5a;
	}
	.box .popupinput{
		width: 52%;text-align: right;display: inline-block;height: 80rpx;line-height: 80rpx;
		padding-right: 30rpx;
		float: right;
	}
	.box .popupinput input{	
		height: 100%;line-height: 100%;
		font-size: 30rpx;
	}
	.inputff{
			color: #BEBEBE;
			font-size:30rpx;
		}
		.box .popupinput{
			font-size:30rpx;
			}
</style>
